<html>
<head><meta charset="utf-8"><title>Difference between Name and NameRef · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html">Difference between Name and NameRef</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="215499106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20Name%20and%20NameRef/near/215499106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html#215499106">(Nov 03 2020 at 19:21)</a>:</h4>
<p>I might be blind and just didn't see anything explaining it but what exactly is the difference between <code>ast::Name</code> and <code>ast::NameRef</code>?</p>



<a name="215499283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20Name%20and%20NameRef/near/215499283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html#215499283">(Nov 03 2020 at 19:23)</a>:</h4>
<div class="codehilite"><pre><span></span><code>fn foo() { foo() }
</code></pre></div>
<p>The first <code>foo</code> is <code>Name</code>, the second one is <code>NameRef</code></p>



<a name="215499322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20Name%20and%20NameRef/near/215499322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html#215499322">(Nov 03 2020 at 19:23)</a>:</h4>
<p>Names define things in scope, NameRefs use previously defined names</p>



<a name="215499341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20Name%20and%20NameRef/near/215499341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html#215499341">(Nov 03 2020 at 19:23)</a>:</h4>
<p>You <em>mostly</em> can figure which is which syntactically</p>



<a name="215499347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20Name%20and%20NameRef/near/215499347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html#215499347">(Nov 03 2020 at 19:23)</a>:</h4>
<p>Ah so it is just that, alright.</p>



<a name="215499352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20Name%20and%20NameRef/near/215499352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html#215499352">(Nov 03 2020 at 19:23)</a>:</h4>
<p>Is there a way to go from one to the other?</p>



<a name="215499401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20Name%20and%20NameRef/near/215499401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html#215499401">(Nov 03 2020 at 19:24)</a>:</h4>
<p>I seem to need that for the <code>make</code> module</p>



<a name="215499456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20Name%20and%20NameRef/near/215499456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html#215499456">(Nov 03 2020 at 19:24)</a>:</h4>
<p>for <code>make::record_field</code> to be precise, it currently takes a <code>ast::NameRef</code> due to one use</p>



<a name="215499475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20Name%20and%20NameRef/near/215499475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html#215499475">(Nov 03 2020 at 19:24)</a>:</h4>
<p>Yup, you need <code>make</code> for that</p>



<a name="215499480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20Name%20and%20NameRef/near/215499480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html#215499480">(Nov 03 2020 at 19:24)</a>:</h4>
<p>but i only got an <code>ast::Name</code> now</p>



<a name="215499510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20Name%20and%20NameRef/near/215499510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html#215499510">(Nov 03 2020 at 19:25)</a>:</h4>
<p>ah oaky i guess i can do it via <code>make</code> <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="215499515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20Name%20and%20NameRef/near/215499515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html#215499515">(Nov 03 2020 at 19:25)</a>:</h4>
<p><code>make::name_ref(name.text())</code> or smth along this lines would work</p>



<a name="215499539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20Name%20and%20NameRef/near/215499539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20Name.20and.20NameRef.html#215499539">(Nov 03 2020 at 19:25)</a>:</h4>
<p>thanks <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>